package com.example.consumer.dubbo.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.dubbo.service.StudentService;
import com.example.model.Student;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class JspController {
  @Reference(interfaceClass = StudentService.class, version = "1.0.0", check = false)
  private StudentService studentService;

  @RequestMapping(value = "/jsp2")
  public String jsp(Model model) {
    model.addAttribute("data", "前端使用jsp");

    return "index";
  }

  @GetMapping(value = "/student/detail/{id}")
  public String studentDetail(Model model, @PathVariable("id") Integer id) {

    Student student = studentService.queryStudentById(id);
    model.addAttribute("student", student);

    return "studentDetail";
  }
}
